/* eslint-disable @typescript-eslint/consistent-type-assertions */
import { createModel } from 'ice';

export interface UserState {
  currentUser?: {
    id?: string;
    username?: string;
    email?: string;
    phone?: string;
    role?: string;
    status?: boolean;
    avatar?: string;
    lastLoginTime?: string;
    remark?: string;
  };
}

export default createModel({
  state: {
    currentUser: undefined,
  } as UserState,

  reducers: {
    updateUserInfo(state: UserState, payload: UserState['currentUser']) {
      state.currentUser = payload;
    },
    clearUserInfo(state: UserState) {
      state.currentUser = undefined;
    },
  },
});
